package coroutines.coroutinebuilder

import kotlinx.coroutines.CoroutineStart
import kotlinx.coroutines.async
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlin.system.measureTimeMillis

class AsyncLazyTest {
}

fun main() {
    val time = measureTimeMillis {
        runBlocking {
            val asyncA = async(start = CoroutineStart.LAZY) {
                delay(3000)
                1
            }

            val asyncB = async(start = CoroutineStart.LAZY) {
                delay(4000)
                2
            }

//            println("asyncA.await()(${asyncA.await()}) + asyncB.await()(${asyncB.await()}) = ${asyncA.await() + asyncB.await()}")
            println("asyncA.await() + asyncB.await() = ${asyncA.await() + asyncB.await()}")
        }
    }

    println("time = ${time}")
}